home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 12 / Cream of the Crop 12 (Part II) / Cream of the Crop 12 (Part II).iso / BBS / SDLOCO14.ZIP / MODULE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-19  |  21.1 KB  |  641 lines

  1. //////////////////////////////////////////////////////////////////////////
  2. // MODULE.C: An example for a module run from one of stardock loco's expansion
  3. // slots.  Feel free to use this code for any stardock loco modules.
  4.  
  5. // This was compiled using Borland Turbo C++ version 3.0
  6. // This will _not_ compile without Brian Pirie's Opendoors odoorh.lib (huge model)
  7.  
  8. // Also feel free to upgrade my version of Guido's Black Market.
  9. // Note: It is crucial to the game that they be able to upgrade their
  10. // armor and weapon strength at the higher levels!  Make sure to keep that
  11. // if you make a better black market.
  12.  
  13. /////////////////////////////////////////////////////////////////////////////
  14. // Do not distribute any modules that use unregistered serial comm libraries!
  15. /////////////////////////////////////////////////////////////////////////////
  16.  
  17. // Ok, enough of that, here's how I call this program.  This is the actual
  18. // code that I use to spawn _from_ stardock loco for anyone that goes into the
  19. // black market:    i.e. blkmkt1.exe
  20. //
  21. // Note:  This is nearly identical to, and works the same way from any expansion
  22. // slots in the game.  The 'Yards expansion slots gets the filepath from
  23. // the module.lst, and does the same thing as below.  The other slots
  24. // are run by using _dos_find_first to find the first occurance of the first
  25. // two letters.  See sd_devlp.txt for all the gruesome details.
  26. //
  27. // any od_control structure usage is from Brian Pirie's Opendoors 5.0 serial
  28. // comm library.  Get his program and register it.
  29. //
  30. // od_control.od_force_local has a boolean value of 1 (TRUE) if the game
  31. // has been set to run locally.
  32. //
  33. // od_control.info_path is the path to the door.sys, or whatever the file
  34. // is that has the BBS information on the user.
  35. //
  36. //  if it's not a local run game, copy the door file path to _argv
  37. //
  38. //    if(od_control.od_force_local!=TRUE)
  39. //        strcpy(_argv[1],od_control.info_path);
  40. //
  41. //   Make sure it's there, or look for an upgrade to blkmkt2.exe etc.
  42. //
  43. //    if( _dos_findfirst("blkmkt?.exe",_A_NORMAL,&ffblk) ==0)
  44. //        {
  45. //        update_player_file();  //update the player file before spawn
  46. //        od_spawnvpe(P_WAIT,ffblk.name,_argv,NULL);
  47. //        check_it();       //make sure they aren't dead.
  48. //                              - this is for real modules.
  49. //                                the black market won't kill ya.
  50. //        }
  51. //////////////////////////////////////////////////////////////////////////
  52. //
  53. //                         Guido's Black Market
  54. //
  55. //////////////////////////////////////////////////////////////////////////
  56. #include <string.h>
  57. #include <stdlib.h>
  58. #include <stdio.h>
  59. #include <dos.h>
  60. #include <time.h>
  61.  
  62. #include "opendoor.h"
  63. //from Brian Pirie's Opendoors 5.0 serial comm library
  64. //contains all the functions and structures necessary for comm routines.
  65.  
  66. #include <ctype.h>
  67. #include <errno.h>
  68.  
  69. //see sd_devlp.txt for all the information on this stuff.
  70. #define MAX 2
  71. #define MAXNAME  30
  72. #define    MAXBBSNAME 36
  73. #define    MAXWEAPONNAME 20
  74. #define    MAXARMORNAME 20
  75. #define MAXSTANDARDLONG 10
  76. #define MAXSTANDARDINT 4  //standard integer
  77. #define WAIT_FOR_FILE         10       /* Time to wait for access to file */
  78. FILE *OpenExclusiveFile(char *pszFileName, char *pszAccess, time_t Wait); //exclusive file access
  79. void update_player_file(void);
  80. void r_player_file(void);
  81. void WaitForEnter(void);
  82. void More(void);
  83. void door(void);
  84. void indelgos_bm(void);    //the module
  85. void change(void);    //formats numbers to nice numbers with commas
  86.  
  87. struct on_line_player   //See the sd_devlp.txt for further explanations!!
  88.     {
  89.     int on_now;
  90.     char name[MAXNAME+1];
  91.     char bbs_name[MAXBBSNAME+1];
  92.     int living;      //if alive = 1
  93.     char killer[MAXNAME+1];     //who killed player
  94.     int location;    //1 if in TP's, 2 if in pod
  95.     long lifepoints;
  96.     long lifepointsttl;
  97.  
  98.     char weapon[MAXWEAPONNAME+1];
  99.     unsigned long weapon_energy;
  100.     int weapon_strength;
  101.     unsigned long max_packs;
  102.     int weapon_status;
  103.     unsigned long weapon_cost;
  104.  
  105.     char armor[MAXARMORNAME+1];
  106.     unsigned long armor_strength;
  107.     int armor_status;
  108.     unsigned long armor_cost;
  109.  
  110.     unsigned long credits;
  111.     unsigned long bank_credit;
  112.  
  113.     int pod;
  114.  
  115.     int ship;
  116.     char ship_name[MAXNAME+1];
  117.     int ship_type;
  118.     int mt;              //matter transmitter
  119.     int arkon_bomb;
  120.  
  121.     //*extra data:
  122.     int level;
  123.     unsigned long experience;
  124.     int kills;
  125.     int droids;
  126.     int passkey;
  127.  
  128.    //assorted stuff *global* //
  129.     int on_off;    //on off for off-line droid attack
  130.     //reset daily by extern:   //from defaults....
  131.     int sickbay_closed;        //killed staff
  132.     int bank_closed;           //angered guido
  133.     int pickpocket;            //picked N. Wetlys pocket
  134.     int tipcnt;                //max tips taken
  135.     int owns;                 //1 owns weapon shop, 2 owns armor shop
  136.     int fights;                //fights per day 30?
  137.     int last_played;           //stardock days running
  138.     };
  139.  
  140. struct on_line_player current;
  141.  
  142. struct player
  143.     {
  144.     char on_now[MAXSTANDARDINT+1];
  145.     char name[MAXNAME+1];
  146.     char bbs_name[MAXBBSNAME+1];
  147.     char living[MAXSTANDARDINT+1];      //if alive = 1
  148.     char killer[MAXNAME+1];
  149.     char location[MAXSTANDARDINT+1];
  150.     char lifepoints[MAXSTANDARDLONG+1];
  151.     char lifepointsttl[MAXSTANDARDLONG+1];
  152.  
  153.     char weapon[MAXWEAPONNAME+1];
  154.     char weapon_energy[MAXSTANDARDLONG+1];
  155.     char weapon_strength[MAXSTANDARDINT+1];
  156.     char max_packs[MAXSTANDARDLONG+1];
  157.          //if they have a weapon = 1
  158.     char weapon_status[MAXSTANDARDINT+1];
  159.     char weapon_cost[MAXSTANDARDLONG+1];
  160.  
  161.     char armor[MAXARMORNAME+1];
  162.     char armor_strength[MAXSTANDARDLONG+1];
  163.     char armor_status[MAXSTANDARDINT+1];        //if they have armor = 1
  164.     char armor_cost[MAXSTANDARDLONG+1];
  165.  
  166.     char credits[MAXSTANDARDLONG+1];
  167.     char bank_credit[MAXSTANDARDLONG+1];
  168.  
  169.     char pod[MAXSTANDARDINT+1];
  170.  
  171.     char ship[MAXSTANDARDINT+1];
  172.     char ship_name[MAXNAME+1];
  173.     char ship_type[MAXSTANDARDINT+1];
  174.     char mt[MAXSTANDARDINT+1];
  175.     char arkon_bomb[MAXSTANDARDINT+1];
  176.  
  177.     char level[MAXSTANDARDINT+1];
  178.     char experience[MAXSTANDARDLONG+1];
  179.     char kills[MAXSTANDARDINT+1];
  180.     char droids[MAXSTANDARDINT+1];
  181.     char passkey[MAXSTANDARDINT+1];
  182.  
  183.      //globals
  184.     char on_off[MAXSTANDARDINT+1];
  185.     char sickbay_closed[MAXSTANDARDINT+1];
  186.     char bank_closed[MAXSTANDARDINT+1];
  187.     char pickpocket[MAXSTANDARDINT+1];
  188.     char tipcnt[MAXSTANDARDINT+1];
  189.     char owns[MAXSTANDARDINT+1];
  190.     char fights[MAXSTANDARDINT+1];
  191.     char last_played[MAXSTANDARDINT+1];
  192.     };
  193.  
  194.  
  195. int playerfound=0;
  196. char door_sys_name[MAXBBSNAME+1];
  197. int record_count;
  198. char number[14];  //for formatted credit amounts and such.  See change();
  199.  
  200.  
  201.  
  202.  
  203.  
  204. void main(int argc,char *_argv[])
  205. {
  206. int counter;
  207. int sync=0;
  208.  
  209. for(counter=1;counter<argc;++counter)
  210.     {               //look for a /l or -l switch for local mode.
  211.     if((_argv[counter])[1]=='l'||(_argv[counter])[1]=='L')
  212.         {
  213.         od_control.od_force_local=TRUE;  //make opendoors run in local mode
  214.         od_clr_scr();      //clear the screen.
  215.         od_printf("`cyan`╒═════════════════════════════════════════════════════════════╕\n\r");
  216.         od_printf("│`green`STARDOCK LOCO -`cyan` Local Mode  - Black Market                   │\n\r");
  217.         od_printf("╘═════════════════════════════════════════════════════════════╛\n\r");
  218.         od_printf(" Enter your name: ");
  219.         od_input_str(door_sys_name,MAXBBSNAME,32,127);
  220.         door();       //run the door.
  221.         sync=1;       //and make sure the lines below aren't run as well.
  222.         }
  223.       }
  224. if(sync==0)      //skip if local mode.
  225. {
  226. if(argc>1) strncpy(od_control.info_path,_argv[1],59);  //read the door.sys path
  227. od_init();       //opendoors initialization function
  228. strcpy(door_sys_name,od_control.user_name);  //take real name from door.sys
  229. door();
  230. }
  231. }
  232.  
  233. void door(void)
  234. {
  235. r_player_file();   //read the player file, make sure they are there.
  236. if(playerfound==1)     //when it's found do the module
  237. {
  238. indelgos_bm();      //run the module  (originally Indelgo's Black Market)
  239. update_player_file();     //save the changes made, if any.
  240. }
  241. else
  242.     {
  243.     od_printf("\n\rPlayer not found!");  //bad error!
  244.     od_printf("Name Error.");
  245.     WaitForEnter();
  246.     }
  247. }
  248.  
  249.  
  250.  
  251. void indelgos_bm(void)
  252. {
  253. char numstr[10];
  254. unsigned long total=0;
  255. unsigned long amt;
  256. unsigned long cost;
  257. char choice,choice2;
  258. do{
  259. od_clr_scr();
  260. od_printf("╒═════════════════════════════════════════════════════════════╕\n\r");
  261. od_printf("│`green`STARDOCK LOCO -`cyan` Guido's Black Market                         │\n\r");
  262. od_printf("╘═════════════════════════════════════════════════════════════╛\n\r");
  263. od_printf("Looking furtively around you to make sure no one sees you, \n\r");
  264. od_printf("you slip into a small room behind Guido's Bank. \n\r");
  265. od_printf("             <`bright cyan`B`cyan`> Buy droids\n\r");
  266. od_printf("             <`bright cyan`U`cyan`> Upgrade armor\n\r");
  267. od_printf("             <`bright cyan`I`cyan`> Increase weapon strength\n\r");
  268. od_printf("             <`bright cyan`X`cyan`> Exit");
  269. sprintf(number,"%ld",current.credits); //copy the credits amount
  270. change();                              //format it
  271. od_printf("\n\rYour Credits: $`green`%s`cyan`.",number);    //print it
  272. od_printf("\n\rMake your choice: ");
  273. choice=od_get_answer("BUIX\n\r");    //get the correct key
  274. switch(choice)
  275.     {
  276.     case 'B':
  277.         amt=current.level*100000;
  278.         sprintf(number,"%ld",amt);
  279.         change();
  280.         od_printf("\n\rAh, you'd like some `white`droids`cyan`, eh?  They are $`green`%s`cyan` apiece.",number);
  281.         total=current.credits/amt;
  282.         sprintf(number,"%ld",total);
  283.         change();
  284.         od_printf("\n\rYou can buy `bright cyan`%s`cyan` with your credits.",number);
  285.         od_printf("\n\r`bright cyan`How many would you like? `cyan`[0 to exit] ");
  286.         od_input_str(numstr,4,'0','9');
  287.         amt=atoi(numstr);
  288.         if(amt>0)
  289.             {
  290.             cost=amt*(current.level*100000);
  291.             if(cost>current.credits)
  292.                 od_printf("`yellow`\n\rYou haven't enough money..`cyan`");
  293.             else
  294.                 {
  295.                 sprintf(number,"%ld",amt);
  296.                 change();
  297.                 od_printf("\n\rOk, you've bought `green`%s`cyan` droids.",number);
  298.                 od_printf("\n\rI hope you use them `red`wisely`cyan`...");
  299.                 current.credits-=cost;
  300.                 current.droids+=amt;
  301.                 }
  302.             }
  303.             WaitForEnter();
  304.             break;
  305.         case 'U':
  306.             if(current.armor_strength<350000)
  307.                 {
  308.                 od_printf("\n\rUpgrade that armor?  `bright cyan`NEVER!`cyan`");
  309.                 od_printf("\n\rGive me something to work with here!!!");
  310.                 }
  311.             else
  312.             {
  313.             od_printf("\n\rIt costs $`bright cyan`100,000,000`cyan` to upgrade your armor");
  314.             sprintf(number,"%ld",current.armor_strength);
  315.             change();
  316.             od_printf("\n\rfrom `bright cyan`%s`cyan` to ",number);
  317.             sprintf(number,"%ld",(current.armor_strength+50000));
  318.             change();
  319.             od_printf("`bright cyan`%s`cyan`.",number);
  320.             od_printf("\n\r`bright cyan`Do you wish to upgrade your armor? [Y/N]`cyan`");
  321.             choice2=od_get_answer("YN\n\r");
  322.             switch(choice2)
  323.                 {
  324.                 case 'N':
  325.                     break;
  326.                 case 'Y':
  327.                 default:
  328.                     if(current.armor_strength<2000000000)//<-this has changed.  Heck if I remember. <G>
  329.                         {
  330.                         if(current.credits>=100000000)
  331.                             {
  332.                             current.credits-=100000000;
  333.                             current.armor_strength+=50000;
  334.                             sprintf(number,"%ld",current.armor_strength);
  335.                             change();
  336.                             od_printf("\n\rOk, your armor has been upgraded to `bright cyan`%s!`cyan`",number);
  337.                             }
  338.                         else
  339.                             od_printf("\n\rYou don't have enough money!");
  340.                         }
  341.                     else
  342.                         od_printf("\n\rSorry, your armor is MAXED!!!!");
  343.  
  344.                   }
  345.             }
  346.         WaitForEnter();
  347.         break;
  348.         case 'I':
  349.             if(current.weapon_strength<1000) //<-this may be different now.
  350.                 od_printf("\n\rWe only upgrade `bright cyan`Crowley's Cannons`cyan` or better here!");
  351.             else
  352.             {
  353.             od_printf("\n\rI'll give you a great deal on an `bright cyan`O.S.S.C Overcharge Pack!`cyan`");
  354.             od_printf("\n\rOnly cost you $`bright cyan`100,000,000`cyan` for an increase from `bright cyan`%d`cyan` to `bright cyan`%d`cyan`!",current.weapon_strength,current.weapon_strength+3);
  355.             od_printf("\n\r`bright cyan`Do you wish to buy one? [Y/N]`cyan` ");
  356.             choice2=od_get_answer("YN\n\r");
  357.             switch(choice2)
  358.                 {
  359.                 case 'N':
  360.                     break;
  361.                 case 'Y':
  362.                 default:
  363.                     if(current.weapon_strength<125)
  364.                         {
  365.                         if(current.credits>=100000000)
  366.                             {
  367.                             od_printf("\n\rOk, your `bright cyan`%s`cyan` has been upgraded!",current.weapon);
  368.                             current.credits-=100000000;
  369.                             current.weapon_strength+=3;
  370.                             }
  371.                         else
  372.                             od_printf("\n\rYou don't have enough money!");
  373.                         }
  374.                     else
  375.                         od_printf("\n\rSorry, your weapon is MAXED!!!!");
  376.                 }
  377.             }
  378.         WaitForEnter();
  379.         break;
  380.         case 'X':
  381.         default:
  382.             choice='X';
  383.             break;
  384.         }
  385. }while(choice!='X');
  386. }
  387.  
  388.  
  389. void r_player_file(void)        //initial read of the player file
  390. {                               //see sd_devlp.txt for more info.
  391. int k;
  392.  
  393. struct player *names;
  394. int p=0;
  395. FILE *fptr;
  396. record_count=0;
  397. if((names=(struct player*) calloc(100,sizeof(struct player)))==NULL)
  398.     {
  399.     od_printf("\n\rNot enough memory for Player.lst");
  400.     WaitForEnter();
  401.     }
  402. else
  403. {
  404.     fptr = OpenExclusiveFile("player.lst", "rb", WAIT_FOR_FILE);
  405.     while( fread(&names[record_count],sizeof(names[record_count]),1,fptr)==1)
  406.         record_count++;
  407.        fclose(fptr);
  408.        }
  409.  
  410.                //check for a match of name[p].bbs_name
  411.               //against door_sys_name
  412. for(p=0;p<record_count;p++)
  413.     { //begin for
  414.     if (stricmp (door_sys_name,names[p].bbs_name) ==0)
  415.         {  //begin if
  416.         playerfound=1;     //player is found...
  417.         strcpy(current.name,names[p].name);
  418.         strcpy(current.bbs_name,names[p].bbs_name);
  419.         current.living=atoi(names[p].living);
  420.         strcpy(current.killer,names[p].killer);
  421.         current.location=atoi(names[p].location);
  422.         current.lifepoints=atol(names[p].lifepoints);
  423.         current.lifepointsttl=atol(names[p].lifepointsttl);
  424.  
  425.         strcpy(current.weapon,names[p].weapon);
  426.         current.weapon_energy=atol(names[p].weapon_energy);
  427.         current.weapon_strength=atoi(names[p].weapon_strength);
  428.         current.max_packs=atol(names[p].max_packs);
  429.  
  430.         current.weapon_status=atoi(names[p].weapon_status);
  431.         current.weapon_cost=atol(names[p].weapon_cost);
  432.  
  433.         strcpy(current.armor,names[p].armor);
  434.         current.armor_strength=atol(names[p].armor_strength);
  435.         current.armor_status=atoi(names[p].armor_status);
  436.         current.armor_cost=atol(names[p].armor_cost);
  437.  
  438.         current.credits=atol(names[p].credits);
  439.         current.bank_credit=atol(names[p].bank_credit);
  440.  
  441.         current.pod=atoi(names[p].pod);
  442.  
  443.         current.ship=atoi(names[p].ship);
  444.         strcpy(current.ship_name,names[p].ship_name);
  445.         current.ship_type=atoi(names[p].ship_type);
  446.         current.mt=atoi(names[p].mt);
  447.         current.arkon_bomb=atoi(names[p].arkon_bomb);
  448.  
  449.         current.level=atoi(names[p].level);
  450.         current.kills=atoi(names[p].kills);
  451.         current.experience=atol(names[p].experience);
  452.         current.droids=atoi(names[p].droids);
  453.         current.passkey=atoi(names[p].passkey);
  454.  
  455.         current.on_off=atoi(names[p].on_off);
  456.         current.sickbay_closed=atoi(names[p].sickbay_closed);
  457.         current.bank_closed=atoi(names[p].bank_closed);
  458.         current.pickpocket=atoi(names[p].pickpocket);
  459.         current.tipcnt=atoi(names[p].tipcnt);
  460.         current.owns=atoi(names[p].owns);
  461.         current.fights=atoi(names[p].fights);
  462.         current.last_played=atoi(names[p].last_played);
  463.  
  464.         p=record_count;
  465.         }    //end if
  466.      else playerfound=0;
  467.     }  //end for
  468. free(names);
  469. }
  470.  
  471. void update_player_file(void) //update the changes to the file.
  472. {
  473. int p=0;
  474.  
  475.  
  476. struct player *names;
  477.  
  478. FILE *fptr;
  479. if((names=(struct player*) calloc(100,sizeof(struct player)))==NULL)
  480.     {
  481.     od_printf("\n\rNot enough memory for player.lst");
  482.     WaitForEnter();
  483.     }
  484. else
  485. {
  486.                //READ player file
  487.     fptr = OpenExclusiveFile("player.lst", "rb", WAIT_FOR_FILE);
  488.     while( fread(&names[p],sizeof(names[p]),1,fptr)==1)
  489.          {
  490.           if (stricmp (names[p].bbs_name,current.bbs_name) ==0)
  491.         {
  492.             //when found copy data to text file
  493.           sprintf(names[p].on_now, "%d",current.on_now);
  494.           strncpy(names[p].name,current.name,sizeof(current.name));
  495.           strncpy(names[p].bbs_name,current.bbs_name,sizeof(current.bbs_name));
  496.           sprintf(names[p].living, "%d", current.living);
  497.           strncpy(names[p].killer,current.killer,sizeof(current.killer));
  498.           sprintf(names[p].location, "%d",current.location);
  499.           sprintf(names[p].lifepoints, "%ld", current.lifepoints);
  500.           sprintf(names[p].lifepointsttl, "%ld", current.lifepointsttl);
  501.  
  502.           strncpy(names[p].weapon,current.weapon,sizeof(current.weapon));
  503.           sprintf(names[p].weapon_energy, "%ld", current.weapon_energy);
  504.           sprintf(names[p].weapon_strength, "%d", current.weapon_strength);
  505.           sprintf(names[p].max_packs, "%ld", current.max_packs);
  506.  
  507.           sprintf(names[p].weapon_status, "%d", current.weapon_status);
  508.           sprintf(names[p].weapon_cost, "%ld", current.weapon_cost);
  509.  
  510.           strncpy(names[p].armor,current.armor,sizeof(current.armor));
  511.           sprintf(names[p].armor_strength, "%ld", current.armor_strength);
  512.           sprintf(names[p].armor_status, "%d", current.armor_status);
  513.           sprintf(names[p].armor_cost, "%ld", current.armor_cost);
  514.  
  515.           sprintf(names[p].credits, "%ld", current.credits);
  516.           sprintf(names[p].bank_credit, "%ld", current.bank_credit);
  517.  
  518.           sprintf(names[p].pod,"%d",current.pod);
  519.  
  520.           sprintf(names[p].ship,"%d",current.ship);
  521.           strncpy(names[p].ship_name,current.ship_name,sizeof(current.ship_name));
  522.           sprintf(names[p].ship_type,"%d",current.ship_type);
  523.           sprintf(names[p].mt,"%d",current.mt);
  524.           sprintf(names[p].arkon_bomb,"%d",current.arkon_bomb);
  525.  
  526.           sprintf(names[p].level, "%d", current.level);
  527.           sprintf(names[p].experience, "%ld", current.experience);
  528.           sprintf(names[p].kills, "%d", current.kills);
  529.           sprintf(names[p].droids, "%d", current.droids);
  530.           sprintf(names[p].passkey, "%d", current.passkey);
  531.  
  532.           sprintf(names[p].on_off,"%d",current.on_off);
  533.           sprintf(names[p].sickbay_closed,"%d",current.sickbay_closed);
  534.           sprintf(names[p].bank_closed,"%d",current.bank_closed);
  535.           sprintf(names[p].pickpocket,"%d",current.pickpocket);
  536.           sprintf(names[p].tipcnt,"%d",current.tipcnt);
  537.           sprintf(names[p].owns,"%d",current.owns);
  538.           sprintf(names[p].fights,"%d",current.fights);
  539.           sprintf(names[p].last_played,"%d",current.last_played);
  540.           }
  541.         p++;
  542.          }
  543.        fclose(fptr);
  544.  
  545.  
  546.         //write the file
  547.     fptr = OpenExclusiveFile("player.lst", "wb", WAIT_FOR_FILE);
  548.     fwrite(names,sizeof(struct player), p, fptr);
  549.     fclose(fptr);
  550. free(names);
  551. }
  552. }
  553.     //exclusive file access routine by Brian Pirie, Opendoors 5.0
  554.     //Get his stuff, it's good!  Register it as well.
  555. FILE *OpenExclusiveFile(char *pszFileName, char *pszAccess, time_t Wait)
  556. {
  557.    FILE *pfFile;
  558.    time_t StartTime = time(NULL);
  559.  
  560.    for(;;)
  561.    {
  562.       /* Attempt to open file */
  563.       pfFile = fopen(pszFileName, pszAccess);
  564.  
  565.       /* If file was opened successfuly, then exit */
  566.       if(pfFile != NULL) break;
  567.  
  568.       /* If open failed, but not due to access failure, then exit */
  569.       if(errno != EACCES) break;
  570.  
  571.       /* If maximum time has elapsed, then exit */
  572.       if(StartTime + Wait < time(NULL)) break;
  573.  
  574.       /* Give the OpenDoors kernel a chance to execute before trying again */
  575.       od_kernel();
  576.    }
  577.  
  578.    /* Return pointer to file, if opened */
  579.    return(pfFile);
  580. }
  581.  
  582. void WaitForEnter(void)
  583. {
  584.    od_printf("\n\r\n\r");  //display prompt
  585.    od_printf("`cyan`Press `green`[ENTER]`cyan` to continue.\n\r");
  586.    od_get_answer("\n\r");  //get a line feed or carriage return
  587. }
  588.  
  589. void More(void)
  590. {
  591.    od_printf("\n\r\n\r");
  592.    od_printf("`cyan`<ENTER>`cyan`\n\r");
  593.    od_get_answer("\n\r");
  594. }
  595.  
  596. void change(void)  //convert the character string to a formatted char string.
  597. {
  598. switch(strlen(number))
  599.     {        //it's ooooogly, but it works.  I'm sure there is a routine
  600.     case 0:  //built for this, but I couldn't find it.  Use it if you like.
  601.          //I left it with the 00 for 0 amounts.  So what!  <G>
  602.          //heck, I wish I would've learned pointers before doing this
  603.          //but, oh well.  Why change it now?  I got other things to do,
  604.          //like write comments all over the place, and really mess it up.
  605.         number[0]='\x0';
  606.     case 1:
  607.         number[1]='0';
  608.     case 2:
  609.         number[2]='\x0';
  610.     case 3:
  611.         sprintf(number,"%c%c%c",number[0],number[1],number[2]);
  612.         break;
  613.     case 4:
  614.         sprintf(number,"%c,%c%c%c",number[0],number[1],number[2],number[3]);
  615.         break;
  616.     case 5:
  617.         sprintf(number,"%c%c,%c%c%c",number[0],number[1],number[2],number[3],number[4]);
  618.         break;
  619.     case 6:
  620.         sprintf(number,"%c%c%c,%c%c%c",number[0],number[1],number[2],number[3],number[4],number[5]);
  621.         break;
  622.     case 7:
  623.         sprintf(number,"%c,%c%c%c,%c%c%c",number[0],number[1],number[2],number[3],number[4],number[5],number[6]);
  624.         break;
  625.     case 8:
  626.         sprintf(number,"%c%c,%c%c%c,%c%c%c",number[0],number[1],number[2],number[3],number[4],number[5],number[6],number[7]);
  627.         break;
  628.     case 9:
  629.         sprintf(number,"%c%c%c,%c%c%c,%c%c%c",number[0],number[1],number[2],number[3],number[4],number[5],number[6],number[7],number[8]);
  630.         break;
  631.     case 10:
  632.         sprintf(number,"%c,%c%c%c,%c%c%c,%c%c%c",number[0],number[1],number[2],number[3],number[4],number[5],number[6],number[7],number[8],number[9]);
  633.         break;
  634.     default:
  635.         sprintf(number,"%c%c%c,%c%c%c,%c%c%c,%c%c%c",number[0],number[1],number[2],number[3],number[4],number[5],number[6],number[7],number[8],number[9],number[10],number[11]);
  636.         break;
  637.     }
  638.  
  639. }
  640.  
  641.